package com.example.design.utils;
import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class XMLUtils {
	
	public static Object getBean(String fileName, String tagName) {
		DocumentBuilderFactory  documentBuilderFactory = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
			Document doc = documentBuilder.parse(new File(fileName));
			NodeList nodeList = doc.getElementsByTagName(tagName);
			Node classNode = nodeList.item(0).getFirstChild();
			String cName = classNode.getNodeValue();
			System.out.println(cName);
			//Class clazz = Class.forName(cName);
			//Object object = clazz.newInstance();
			return cName;
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
